package com.wd.tw.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.wd.tw.domain.entity.ElevatorCameraBox;
import com.wd.tw.service.ElevatorCameraBoxService;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wd.common.core.controller.BaseController;
import com.wd.common.core.domain.HttpResponse;
import com.wd.common.annotation.Log;
import com.wd.common.enums.BusinessType;
import com.wd.common.utils.poi.ExcelUtil;


/**
 * 相机及盒子映射Controller
 * 
 * @author liumingkun
 * @date 2025-01-07
 */
@RestController
@RequestMapping("/business/box")
public class ElevatorCameraBoxController extends BaseController
{
    @Resource
    private ElevatorCameraBoxService elevatorCameraBoxService;

    /**
     * 查询相机及盒子映射列表
     */
    @PreAuthorize("@ss.hasPermi('business:box:list')")
    @GetMapping("/list")
    public HttpResponse list(ElevatorCameraBox elevatorCameraBox)
    {
        startPage();
        List<ElevatorCameraBox> list = elevatorCameraBoxService.selectElevatorCameraBoxList(elevatorCameraBox);
        return HttpResponse.successData(getDataTable(list));
    }

    /**
     * 导出相机及盒子映射列表
     */
    @PreAuthorize("@ss.hasPermi('business:box:export')")
    @Log(title = "相机及盒子映射", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ElevatorCameraBox elevatorCameraBox)
    {
        List<ElevatorCameraBox> list = elevatorCameraBoxService.selectElevatorCameraBoxList(elevatorCameraBox);
        ExcelUtil<ElevatorCameraBox> util = new ExcelUtil<ElevatorCameraBox>(ElevatorCameraBox.class);
        util.exportExcel(response, list, "相机及盒子映射数据");
    }

    /**
     * 获取相机及盒子映射详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:box:query')")
    @GetMapping(value = "/{cameraBoxId}")
    public HttpResponse getInfo(@PathVariable("cameraBoxId") Long cameraBoxId)
    {
        return successData(elevatorCameraBoxService.selectElevatorCameraBoxByCameraBoxId(cameraBoxId));
    }

    /**
     * 新增相机及盒子映射
     */
    @PreAuthorize("@ss.hasPermi('business:box:add')")
    @Log(title = "相机及盒子映射", businessType = BusinessType.INSERT)
    @PostMapping
    public HttpResponse add(@RequestBody ElevatorCameraBox elevatorCameraBox)
    {
        return getResult(elevatorCameraBoxService.insertElevatorCameraBox(elevatorCameraBox));
    }

    /**
     * 修改相机及盒子映射
     */
    @PreAuthorize("@ss.hasPermi('business:box:edit')")
    @Log(title = "相机及盒子映射", businessType = BusinessType.UPDATE)
    @PutMapping
    public HttpResponse edit(@RequestBody ElevatorCameraBox elevatorCameraBox)
    {
        return getResult(elevatorCameraBoxService.updateElevatorCameraBox(elevatorCameraBox));
    }

    /**
     * 删除相机及盒子映射
     */
    @PreAuthorize("@ss.hasPermi('business:box:remove')")
    @Log(title = "相机及盒子映射", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cameraBoxIds}")
    public HttpResponse remove(@PathVariable Long[] cameraBoxIds)
    {
        return getResult(elevatorCameraBoxService.deleteElevatorCameraBoxByCameraBoxIds(cameraBoxIds));
    }
}
